
import bpy

import 全局控制.Node.插座.bl_插座基类 as 插座基类
import 节点.Core.bl_UI配色 as 配色

import engine.initLIB.load_dll as engineLib
import ctypes







def f_socketListFloat_Update(self, context):
	data = [list("初始值"), float(self.default_value)]
	engineLib.flexCAPI.f_bl_插座传入数据(ctypes.c_wchar_p(self.node.id_data.name), 
										ctypes.c_wchar_p(self.node.name), 
										ctypes.c_wchar_p(self.identifier), 
										ctypes.py_object(data),
										ctypes.c_bool(bool(self.is_output))
										)
	#print('f_socketListFloat_Update = ', context, self)
	if context :
		self.node.id_data.f_节点数据更新_更新树([self.node])


def f_socketListInt_Update(self, context):
	data = [list("初始值"), int(self.default_value)]
	engineLib.flexCAPI.f_bl_插座传入数据(ctypes.c_wchar_p(self.node.id_data.name), 
										ctypes.c_wchar_p(self.node.name), 
										ctypes.c_wchar_p(self.identifier), 
										ctypes.py_object(data),
										ctypes.c_bool(bool(self.is_output))
										)
	#print('f_socketListInt_Update = ', context, self)
	if context :
		self.node.id_data.f_节点数据更新_更新树([self.node])














class C_Socket_Bool_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.BoolProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_Bool_Array1D, self).__init__()
		
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[Bool]')

	def draw_color(self, context, node):
		return 配色.g_单值Array1D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketListFloat_Update(self, None)
	def f_update(self):
		f_socketListInt_Update(self, None)












class C_Socket_I8_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update, min=-128, max=128)
	def __init__(self):
		super(C_Socket_I8_Array1D, self).__init__()
		
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[I8]')

	def draw_color(self, context, node):
		return 配色.g_单值Array1D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketListFloat_Update(self, None)
	def f_update(self):
		f_socketListInt_Update(self, None)




class C_Socket_I8_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_I8_Array2D, self).__init__()
		
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text='[[I8]]:'+text)

	def draw_color(self, context, node):
		return 配色.g_单值Array2D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketListFloat_Update(self, None)
	def f_update(self):
		f_socketListInt_Update(self, None)









class C_Socket_F32_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatProperty(update=f_socketListFloat_Update)
	def __init__(self):
		super(C_Socket_F32_Array1D, self).__init__()
		self.display_shape = 'SQUARE_DOT'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[F32]')
		
		
	def draw_color(self, context, node):
		return 配色.g_单值Array1D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketListFloat_Update(self, None)
	def f_update(self):
		f_socketListFloat_Update(self, None)
		





class C_Socket_F32_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.FloatProperty(update=f_socketListFloat_Update)
	def __init__(self):
		super(C_Socket_F32_Array2D, self).__init__()
		self.display_shape = 'SQUARE_DOT'
	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[[F32]]')
		
		
	def draw_color(self, context, node):
		return 配色.g_单值Array2D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketListFloat_Update(self, None)
	def f_update(self):
		f_socketListFloat_Update(self, None)






class C_Socket_I32_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_I32_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[I32]')
		
		
	def draw_color(self, context, node):
		return 配色.g_单值Array1D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		self.default_value = data
		f_socketListInt_Update(self, None)
	def f_update(self):
		f_socketListInt_Update(self, None)




class C_Socket_I32_Array2D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_I32_Array2D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[[I32]]')
		
	def draw_color(self, context, node):
		return 配色.g_单值Array2D插座颜色
		
	def f_getData(self):
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketListInt_Update(self, None)










class C_Socket_UI32_Array1D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_UI32_Array1D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[UI32]')
		
	def draw_color(self, context, node):
		return 配色.g_单值Array1D插座颜色
		
	def f_getData(self):
		return []
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketListInt_Update(self, None)




class C_Socket_UI32_Arrat2D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_UI32_Arrat2D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[[UI32]]')
		
	def draw_color(self, context, node):
		return (0.0, 0.0, 1.0, 1.0)
		
	def f_getData(self):
		return []
	def f_setData(self, data):
		pass
	def f_update(self):
		f_socketListInt_Update(self, None)









class C_Socket_UI32_Array3D(插座基类.C_Socket_基类):
	default_value = bpy.props.IntProperty(update=f_socketListInt_Update)
	def __init__(self):
		super(C_Socket_UI32_Array3D, self).__init__()

	def draw(self, context, layout, node, text):
		if self.is_output == False and self.is_linked == False :
			layout.prop( self, 'default_value', text=text )
		else:
			layout.label(text=text+':[[UI32]]')
			
	def draw_color(self, context, node):
		return (0.0, 0.0, 1.0, 1.0)
		
	def f_getData(self):
		return []
	def f_setData(self, data):
		self.default_value = data
		f_socketListInt_Update(self, None)
	def f_update(self):
		f_socketListInt_Update(self, None)












classes = (
	C_Socket_Bool_Array1D,

	
	C_Socket_I8_Array1D,
	C_Socket_I8_Array2D,

	C_Socket_F32_Array1D,
	C_Socket_F32_Array2D,

	C_Socket_I32_Array1D,
	C_Socket_I32_Array2D,

	C_Socket_UI32_Array1D,
	C_Socket_UI32_Arrat2D,
	C_Socket_UI32_Array3D,
	
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
	pass	

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)
	pass
	








